
var appId = document.getElementById("appid").innerText;
var timestamp = parseInt(document.getElementById("timestamp").innerText);
var noncestr = document.getElementById("noncestr").innerText;
var ticket = document.getElementById("ticket").innerText;
console.log(appId,timestamp,noncestr,ticket);

localStorage.setItem("timestamp", timestamp);
localStorage.setItem("noncestr", noncestr);
localStorage.setItem("ticket", ticket);

var str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp="
		+ timestamp + "&url=" + location.href;
var sha1 = CryptoJS.SHA1(str);
wx.config({
	beta : true,
	debug : false,
	appId : appId,
	timestamp : timestamp,
	nonceStr : noncestr,
	signature : sha1.toString(),
	jsApiList : [ "configWXDeviceWiFi" ]
});
wx.ready(function() {
	/*
	 * wx.checkJsApi({ jsApiList: ['configWXDeviceWiFi'], //
	 * 需要检测的JS接口列表，所有JS接口列表见附录2, success: function(res) { //
	 * 以键值对的形式返回，可用的api值true，不可用为false //
	 * 如：{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
	 * console.info("当前客户端是否支持airkiss "+res.errMsg); alert("当前客户端是否支持airkiss->
	 * "+res.errMsg); }, fail:function(err){
	 * console.info("checkJsApi检查接口失败"+err.errMsg); } });
	 */
	document.querySelector("#scanQRCode0").onclick = function() {
		wx.invoke("configWXDeviceWiFi", {},
				function(res) {
					if (res.err_msg == "configWXDeviceWiFi:ok") {
						console.log("configWXDeviceWiFi is successed. ");
						jump();
					} else if (res.err_msg == "configWXDeviceWiFi:fail") {
						console.log("configWXDeviceWiFi is failed. "
								+ res.err_msg);
						alert("WiFi配置失败，请重按开发平台的WiFi配置按键");
					} else if (res.err_msg == "configWXDeviceWiFi:cancel") {
						console.log("configWXDeviceWiFi is cancel. "
								+ res.err_msg);
						// alert("WiFi配置取消");
					} else {
						alert("调起airkiss失败，请退出重试！ ");
						console.log("注入configWXDeviceWiFi错误信息： "
								+ JSON.stringify(res));
					}
					console.log(JSON.stringify(res));
				});
	};
});

wx.error(function(res) {
	alert("微信配置错误：" + res.errMsg);
});